//
//  XMCollectionFlowLayout.h
//  XunMi
//
//  Created by MacBook on 2024/2/18.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class XMCollectionFlowLayout;

@protocol XMCollectionFlowLayoutDataSource <NSObject>

@required
/// Return per section's column number(must be greater than 0).
- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout numberOfColumnInSection:(NSInteger)section;

/// Return per item's height
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout itemWidth:(CGFloat)width
    heightForItemAtIndexPath:(NSIndexPath *)indexPath;

@optional
/// Column spacing between columns
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
/// The spacing between rows and rows
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;
///
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout insetForSectionAtIndex:(NSInteger)section;
/// Return per section header view height.
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout referenceHeightForHeaderInSection:(NSInteger)section;
/// Return per section footer view height.
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(XMCollectionFlowLayout *)layout referenceHeightForFooterInSection:(NSInteger)section;

@end


@interface XMCollectionFlowLayout : UICollectionViewLayout
@property (nonatomic, weak) id<XMCollectionFlowLayoutDataSource> dataSource;
@property (nonatomic, assign) CGFloat minimumLineSpacing; // default 0.0
@property (nonatomic, assign) CGFloat minimumInteritemSpacing; // default 0.0
@property (nonatomic, assign) IBInspectable BOOL sectionHeadersPinToVisibleBounds; // default NO
@end

NS_ASSUME_NONNULL_END
